package com.af.robot.util.imp;

import com.af.robot.util.Manager;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.io.*;

@Component
public class NginxManager extends Manager {
    @Override
    public boolean start(String Splicing) {
        try {
            String[] split = Splicing.split("<");
            Runtime rt = Runtime.getRuntime();
            rt.exec("cmd.exe /c start " + split[1],null,new File(split[0]));
            return true;
        } catch (Exception e){
            return false;
        }
    }

    @Override
    public boolean stop(String Splicing) {
        try {
            String[] split = Splicing.split("<");
            Runtime rt = Runtime.getRuntime();
            rt.exec("cmd.exe /c " + split[1] + " -s stop",null,new File(split[0]));
            return true;
        } catch (Exception e){
            return false;
        }
    }
}
